import {
  GetCartList
} from '@api/api';

const state = {
  cart: 0
}

const mutations = {
  SET_CART: (state, num) => {
    state.cart = num
  },
}

const actions = {
  getCartNum({ commit }, userInfo) {
    return new Promise((resolve, reject) => {
      GetCartList()
        .then(response=>{
          const { totalCount } = response;
          commit('SET_CART', totalCount);
        })
    })
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

